const BaseController = require('../core/BaseController');

class MapController extends BaseController {
  async index() {
     return this.ctx.render('map/map.tpl');
  }

  async convertToBaiduPoint(){
    const res = await this.ctx.service.mapService.convertToBaiduPoint(this.getBody().coords);
    return res !=null?this.success(res):this.error();
  }

  async popupPage(){
    return this.ctx.render('map/popup.tpl',this.getBody());
  }

  async searchKey(){
     const res = await this.ctx.service.mapService.searchQuery(this.getBody().queryKey,this.getBody().location,this.getBody().pageNum);
     return res !=null?this.success(res):this.error();
  }
}

module.exports = MapController;
